function zero(num) {
  return num < 10 ? "0" + num : num;
}
function my_date(temp) {
  let _date = new Date(temp * 1000);
  //   let year = _date.getFullYear()
  return (
    _date.getFullYear() +
    "-" +
    zero(_date.getMonth() + 1) +
    "-" +
    zero(_date.getDate()) +
    " " +
    zero(_date.getHours()) +
    ":" +
    zero(_date.getMinutes()) +
    ":" +
    zero(_date.getSeconds())
  );
}

function time(temp) {
  let now_date = +new Date();
  let time_before = parseInt((now_date - temp) / 1000 / 3600);
  if (time_before < 24) {
    return time_before + "小时前";
  } else {
    let _date = new Date(temp);
    //   let year = _date.getFullYear()
    return (
      // _date.getFullYear() +
      // "-" +
      // zero(_date.getMonth() + 1) +
      // "-" +
      // zero(_date.getDate()) +
      // " " +
      // zero(_date.getHours()) +
      // ":" +
      zero(_date.getMinutes()) + ":" + zero(_date.getSeconds())
    );
  }
}
function time2(seconds) {
  var min = Math.floor(seconds / 60),
    second = (seconds % 60).toFixed(0),
    hour,
    newMin,
    time;

  if (min > 60) {
    hour = Math.floor(min / 60);
    newMin = min % 60;
  }

  if (second < 10) {
    second = "0" + second;
  }
  if (min < 10) {
    min = "0" + min;
  }

  return (time = hour
    ? hour + ":" + newMin + ":" + second
    : min + ":" + second);
}
function transformDate(mytime) {
  let d = new Date(mytime);
  let y = d.getFullYear();
  let m = d.getMonth() + 1 > 10 ? d.getMonth() + 1 : "0" + (d.getMonth() + 1);
  let r = d.getDate() > 10 ? d.getDate() : "0" + d.getDate();
  let h = d.getHours() > 10 ? d.getHours() : "0" + d.getHours();
  let f = d.getMinutes() > 10 ? d.getMinutes() : "0" + d.getMinutes();
  // padStart是ec6新增语法，可以用来自动补0
  let mm = d
    .getSeconds()
    .toString()
    .padStart(2, "0");
  return y + "-" + m + "-" + r + " " + h + ":" + f + ":" + mm;
}

var toHHmmss = function (data) {
  var s;
  var hours = parseInt((data % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  var minutes = parseInt((data % (1000 * 60 * 60)) / (1000 * 60));
  var seconds = (data % (1000 * 60)) / 1000;
  s = (hours < 10 ? ('0' + hours) : hours) + ':' + (minutes < 10 ? ('0' + minutes) : minutes) + ':' + (seconds < 10 ? ('0' + seconds) : seconds);
  return s;
};


function changeLikeCount(count){
  if(count>=100000){
    return (count/10000).toFixed(1) + "万"
  }else{
    return count
  }
}

function transformDate2(mytime) {
  let d = new Date(mytime);
  let y = d.getFullYear();
  let m = d.getMonth() + 1 ;
  let r = d.getDate() > 10 ? d.getDate() : "0" + d.getDate();
  let h = d.getHours() > 10 ? d.getHours() : "0" + d.getHours();
  let f = d.getMinutes() > 10 ? d.getMinutes() : "0" + d.getMinutes();
  // padStart是ec6新增语法，可以用来自动补0
  let mm = d
    .getSeconds()
    .toString()
    .padStart(2, "0");
  return m + "月" + r + "日" ;
}
function transformDate3(mytime) {
  let d = new Date(mytime);
  let y = d.getFullYear();
  let m = d.getMonth() + 1 > 10 ? d.getMonth() + 1 : "0" + (d.getMonth() + 1);
  let r = d.getDate() > 10 ? d.getDate() : "0" + d.getDate();
  let h = d.getHours() > 10 ? d.getHours() : "0" + d.getHours();
  let f = d.getMinutes() > 10 ? d.getMinutes() : "0" + d.getMinutes();
  // padStart是ec6新增语法，可以用来自动补0
  let mm = d
    .getSeconds()
    .toString()
    .padStart(2, "0");
  return y + "." + m + "." + r ;
}
// module.exports = {
//   my_date,
//   my_date2,
//   time,
//   time2,

// };
export default {
  my_date,
  time,
  time2,
  toHHmmss,
  transformDate,
  changeLikeCount,
  transformDate2,
  transformDate3
};
